package com.yss.reportworld.api.factory;

import com.yss.common.core.domain.YssResponse;
import com.yss.reportworld.api.RemoteStatisticReportService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;


/**
 * 报表世界首页信息
 */
@Component
public class RemoteStatisticsReportFallbackFactory implements FallbackFactory<RemoteStatisticReportService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteStatisticsReportFallbackFactory.class);

    @Override
    public RemoteStatisticReportService create(Throwable throwable) {
        log.error("报表世界首页信息失败:{}", throwable.getMessage());
        return new RemoteStatisticReportService() {
            @Override
            public YssResponse<String> getNoticeInfo(String source) {
                return YssResponse.fail("报表世界首页信息失败:" + throwable.getMessage());
            }

            @Override
            public YssResponse<List<String>> getVersionList(String source) {
                return YssResponse.fail("报表世界首页信息失败:" + throwable.getMessage());
            }

            @Override
            public YssResponse<Map<String, Long>> getCount(String source) {
                return YssResponse.fail("报表世界首页信息失败:" + throwable.getMessage());
            }

            @Override
            public YssResponse<Map<String, List<Long>>> getCountVersion(String source) {
                return YssResponse.fail("报表世界首页信息失败:" + throwable.getMessage());
            }

        };
    }
}
